package com.py.credit.entity.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.py.credit.entity.common.OptionalColumn;

public enum CreditRepairTableFieldEnum {
	A000001("cf_subject", "企业名称", "varchar", "input", true, true, new HashMap<String, String>(), "210001", true, true),

	B000001("cf_subject", "姓名", "varchar", "input", true, true, new HashMap<String, String>(), "210003", true, true),

	C000001("cf_subject", "非企业社会团体名称", "varchar", "input", true, true, new HashMap<String, String>(), "100002", true,
			true),

	CF_WSH("cf_wsh", "行政处罚文书号", "varchar", "input", true, true, new HashMap<String, String>(), "", true, true),

	CF_SY("cf_sy", "处罚事由", "varchar", "input", true, true, new HashMap<String, String>(), "", true, true),

	CF_YJ("cf_yj", "处罚依据", "varchar", "input", true, true, new HashMap<String, String>(), "", true, true),

	REPAIR_USER("repair_user", "修复人", "varchar", "input", true, true, new HashMap<String, String>(), "", true, true),

	REPAIR_TIME("repair_time", "修复时间", "timestamp", "input", true, true, new HashMap<String, String>(), "", true,
			false),

	REPAIR_DEPT("repair_dept", "修复单位", "varchar", "input", true, true, new HashMap<String, String>(), "", true, true);

	private String colNameEN;
	private String colNameCN;
	private String type;
	private boolean defaultShow;
	private String widget;
	private boolean fuzzy;
	private HashMap<String, String> widgetValue;
	private boolean searchIsShow;
	private String group;
	private boolean advanceConditionShow;

	private CreditRepairTableFieldEnum(String colNameEN, String colNameCN, String type, String widget,
			boolean defaultShow, boolean fuzzy, HashMap<String, String> widgetValue, String group,
			boolean advanceConditionShow, boolean searchIsShow) {
		this.colNameEN = colNameEN;
		this.colNameCN = colNameCN;
		this.type = type;
		this.widget = widget;
		this.defaultShow = defaultShow;
		this.fuzzy = fuzzy;
		this.widgetValue = widgetValue;
		this.searchIsShow = searchIsShow;
		this.group = group;
		this.advanceConditionShow = advanceConditionShow;

	}

	public boolean isAdvanceConditionShow() {
		return advanceConditionShow;
	}

	public void setAdvanceConditionShow(boolean advanceConditionShow) {
		this.advanceConditionShow = advanceConditionShow;
	}

	public String getColNameEN() {
		return colNameEN;
	}

	public void setColNameEN(String colNameEN) {
		this.colNameEN = colNameEN;
	}

	public String getColNameCN() {
		return colNameCN;
	}

	public void setColNameCN(String colNameCN) {
		this.colNameCN = colNameCN;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public boolean isDefaultShow() {
		return defaultShow;
	}

	public void setDefaultShow(boolean defaultShow) {
		this.defaultShow = defaultShow;
	}

	public String getWidget() {
		return widget;
	}

	public void setWidget(String widget) {
		this.widget = widget;
	}

	public boolean isFuzzy() {
		return fuzzy;
	}

	public void setFuzzy(boolean fuzzy) {
		this.fuzzy = fuzzy;
	}

	public HashMap<String, String> getWidgetValue() {
		return widgetValue;
	}

	public void setWidgetValue(HashMap<String, String> widgetValue) {
		this.widgetValue = widgetValue;
	}

	public boolean isSearchIsShow() {
		return searchIsShow;
	}

	public void setSearchIsShow(boolean searchIsShow) {
		this.searchIsShow = searchIsShow;
	}

	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public static List<OptionalColumn> getOptionalColumns(String kId) {

		List<OptionalColumn> OptionalColumns = new ArrayList<>();
		CreditRepairTableFieldEnum[] values = CreditRepairTableFieldEnum.values();
		for (CreditRepairTableFieldEnum value : values) {
			if (kId.equals(value.getGroup()) || StringUtils.isBlank(value.getGroup())) {
				OptionalColumn optionalColumn = new OptionalColumn(value.getColNameEN(), value.getColNameCN(),
						value.getType(), value.isDefaultShow(), value.getWidget(), value.isFuzzy(),
						value.getWidgetValue(), value.isSearchIsShow());
				OptionalColumns.add(optionalColumn);
			}

		}
		return OptionalColumns;

	}

	public static List<String> getDefaultShowColumnEN(String kId) {

		List<String> columns = new ArrayList<String>();

		CreditRepairTableFieldEnum[] values = CreditRepairTableFieldEnum.values();

		for (CreditRepairTableFieldEnum value : values) {

			if (value.getGroup().equals(kId) || StringUtils.isBlank(value.getGroup())) {

				if (value.isDefaultShow()) {

					columns.add(value.getColNameEN());
				}
			}

		}
		return columns;

	}

	public static List<OptionalColumn> getAdvancedConditionColumns(String kId) {
		List<OptionalColumn> OptionalColumns = new ArrayList<OptionalColumn>();

		CreditRepairTableFieldEnum[] values = CreditRepairTableFieldEnum.values();

		for (CreditRepairTableFieldEnum value : values) {

			if (kId.equals(value.getGroup()) || StringUtils.isBlank(value.getGroup())) {

				if (value.isAdvanceConditionShow()) {

					OptionalColumn optionalColumn = new OptionalColumn(value.getColNameEN(), value.getColNameCN(),
							value.getType(), value.isDefaultShow(), value.getWidget(), value.isFuzzy(),
							value.getWidgetValue(), value.isSearchIsShow());
					OptionalColumns.add(optionalColumn);
				}
			}

		}
		return OptionalColumns;
	}

}
